Let's dissect the 2nd. A well regulated Militia, being necessary to the security of a free State, ( comma, first clause) meaning there has to be a means of defense against enemies, bad guys, whatever you call them. it needs to be equipped on par with the military of the time, and be at least somewhat standardized.
the right of the people to keep and bear Arms, shall not be infringed ( second clause). Since an army of the greatest power in the world was used to suppress the lowly citizens and it could (and has) happen again. (Power corrupts). So regular people had and have the right to own personal firearms equal to those of an army.
If you think guerillas are not equal to taking on a modern military look at Afghanistan